import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

const htmlString = '''
<!DOCTYPE html>
<head>
<title>webview demo | IAM17</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, 
  maximum-scale=1.0, user-scalable=no,viewport-fit=cover" />
<style>
*{
  margin:0;
  padding:0;
}
body{
   background:#BBDFFC;  
   display:flex;
   justify-content:center;
   align-items:center;
   height:100px;
   color:#C45F84;
   font-size:20px;
}
</style>
</head>
<html>
<body>
<div >html String</div>
</body>
</html>
''';

// class WebView extends StatelessWidget {
//   const WebView({super.key});

//   @override
//   Widget build(BuildContext context) {
//     return const MyWebView();
//   }
// }

class MyWebView extends StatefulWidget {
  const MyWebView({super.key});

  @override
  State<MyWebView> createState() => _MyWebViewState();
}

class _MyWebViewState extends State<MyWebView> {
  late final WebViewController controller;
  late final WebViewController controller2;
  double height = 0;
  
  @override
  void initState() {
    controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..loadFile("172.16.30.214:2040/");
      // ..loadHtmlString(htmlString);

    controller2 = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      // ..loadFlutterAsset("./index.html");
      ..loadHtmlString(htmlString);

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [Expanded(child: WebViewWidget(controller: controller), flex: 4), Expanded(child: WebViewWidget(controller: controller2))],
    );
  }
}
